home *** CD-ROM | disk | FTP | other *** search
/ Top 200 Programs / Top 200 Programs.iso / Bob8 / THOMPSON / LIBERTY / PRODUCT / TUTORIAL.EXE / WK1HW1.BAS < prev    next >
BASIC Source File  |  1996-01-24  |  1KB  |  48 lines

  1.  
  2.     'WK1HW1.BAS
  3.     'Week 1, homework solution 1
  4.     'Liberty BASIC programming course
  5.     'Copyright 1996 Shoptalk Systems
  6.     'All Rights Reserved
  7.  
  8. [start]
  9.  
  10.     'Ask for a dollar and cent amount
  11.     print "Type a dollar and cent amount."
  12.     input "(Press 'Enter' alone for help) ?"; amount
  13.  
  14.     'Display help if user pressed [Enter]
  15.     if amount = 0 then [help]
  16.  
  17.     'Calculate tax for the nearest 20 cent multiple
  18.     dollars = int(amount)
  19.     dollarsTax = dollars * 0.05
  20.     cents = amount - dollars
  21.     adjustment = 0.10
  22.     centsAdjusted = cents + adjustment
  23.     centsRounded = int(centsAdjusted / 0.20) * 0.20
  24.     centsTax = (centsRounded / 0.20) / 100
  25.     tax = dollarsTax + centsTax
  26.  
  27.     'Display the amount, tax, and total
  28.     'Add 0.001 to compensate for any loss of precision because
  29.     'we are dealing with monetary values.
  30.     print "Product Price $"; using("#####.##", amount + 0.001)
  31.     print "Sales Tax      "; using("#####.##", tax + 0.001)
  32.     print "------------------------"
  33.     print "Total          "; using("#####.##", tax + amount + 0.001)
  34.     print
  35.     goto [start]
  36.  
  37. [help]
  38.     cls
  39.     print "SALESTAX.BAS Help"
  40.     print
  41.     print "This tax program determines how much tax is"
  42.     print "due on an amount entered and also computes"
  43.     print "the total amount.  The tax rate is 5%."
  44.     print
  45.     input "Press [Enter] to continue."; dummyVariable
  46.     cls
  47.     goto [start]
  48.